package com.formerlyknownasprince.wheresmystuff.models;

import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.node.NullNode;

/**
 * @author      Tim Swihart 		<email obscured since this file is public>
 * @version     0.1                 
 * @since       2013-02-24
 * 
 * This class represents the JSON message format returned by our server
 */
public class JSONMessage {
	@JsonProperty("err")
	private String err;
	
	//@JsonProperty("cls")
	//private String objClass;
	
	@JsonProperty("obj")
	private JsonNode obj;
	
	public JSONMessage() {
		this.setErr("");
		//this.setObjClass("");
		this.obj = NullNode.getInstance();
	};
	
	public JSONMessage(JsonNode root) {
		this.setErr(root.get("err").asText());
		//this.setObjClass(root.get("cls").asText());
		this.setObj(root.get("obj"));
	}
	
	public JSONMessage(String err, String cls, JsonNode obj) {
		this.setErr(err);
		//this.setObjClass(cls);
		this.setObj(obj);
	}

	public JsonNode getObj() {
		return obj;
	}


	public void setObj(JsonNode obj) {
		this.obj = obj;
	}

	public String getErr() {
		return err;
	}

	public void setErr(String err) {
		this.err = err;
	}

	/*public String getObjClass() {
		return objClass;
	}

	public void setObjClass(String objClass) {
		this.objClass = objClass;
	}*/

	
}
